import React from 'react'
import {getProduct} from '../actions/productDetails'
import { connect } from 'react-redux';
import { Card, CardImg, CardText, CardBody,
    CardTitle, CardSubtitle, Button } from 'reactstrap';
const mapStateToProps=(state)=>{
    console.log(state)
    return {
       product:state.product
   } 
}
 class ProductDetails extends React.Component{
     componentDidMount(){
         const id=this.props.match.params.id
         console.log(this.props.getProduct(id));
     }
    render (){
        const {product}=this.props
        return (
            <div>
                <Card >
                <CardImg style={{width:15+'rem',height:15+'rem'}} src={product.img} alt="Card image cap" />
                <CardBody >
                    <CardTitle>{product.name}</CardTitle>
                    <CardText>{product.time}</CardText>
                    <Button>添加到购物车</Button>
                </CardBody>
                </Card>
            </div>
        )
    }
}
export default  connect(mapStateToProps,{getProduct})(ProductDetails)